//
//  ViewController.swift
//  YSM
//
//  Created by ys on 2018/7/13.
//  Copyright © 2018年 ys. All rights reserved.
//

import UIKit

class ThirdViewController: BaseViewController {

    private var textField: UITextField!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.initData()
        self.initView()
        self.registerNotify()
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        let vc  = YSRouter.loadVC(vcName: "假的页面")
        vc.loadVCInfo(params:["title":"假的页面"])
        self.navigationController?.pushViewController(vc, animated: true)
    }
    
    override func loadVCInfo(params: Any) {
        let para = params as? Dictionary<String, Any>
        self.navigationItem.title = para?["title"] as? String
    }
    
    private func initData() {
        
    }
    private func initView() {
        self.textField = UITextField(frame: CGRect(x: 50, y: 100, width: 200, height: 40))
        self.textField.borderStyle = .roundedRect
        self.textField.placeholder = "回传内容"
        self.view.addSubview(self.textField)
        
        let inBtn = UIButton(type: .system)
        inBtn.frame = CGRect(x: 50, y: 200, width: 100, height: 40)
        inBtn.setTitle("登录", for: .normal)
        inBtn.addTarget(self, action: #selector(logInAction), for: .touchUpInside)
        self.view.addSubview(inBtn)
        
        
        let outBtn = UIButton(type: .system)
        outBtn.frame = CGRect(x: 200, y: 200, width: 100, height: 40)
        outBtn.setTitle("退出", for: .normal)
        outBtn.addTarget(self, action: #selector(logOutAction), for: .touchUpInside)
        self.view.addSubview(outBtn)
    }
    
    private func registerNotify() {
        
    }
   
    @objc private func logInAction() {
        
        YSRouterCommon.postRouterCommon(name: .RLoginSucess, params: self.textField.text!)
    }
    
    @objc private func logOutAction() {
        YSRouterCommon.postRouterCommon(name: .RLogout, params: "退出了三级页面")
        self.navigationController?.popViewController(animated: true)

    }


}
